from flask import Flask, render_template
from flask import request

app = Flask(__name__)


@app.route('/')
def index():  # put application's code here
    return render_template('index.html')


@app.route('/user/<name>')
def user(name):  # put application's code here
    return render_template('user.html', name=name)


@app.route('/templates/variable')
def var():
    mylist = list(range(5))
    mydict = {'a': 1, 'b': 2, 'c': 3}
    return render_template('variable.html', mylist=mylist, mydict=mydict, mykey='b', myintvar=3)

@app.route('/templates/<name>')
def ctrl(name):
    comments = ["a", "b", "c"]
    return render_template('control.html', user=name, comments=comments)


@app.route('/browser')
def show_request():
    user_agent = request.headers.get('User-Agent')
    return 'Your browser is {}'.format(user_agent)


if __name__ == '__main__':
    app.run()
